package com.ruicar.afs.cloud.batch.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruicar.afs.cloud.batch.entity.AfsBatchJobGroupInfo;
import com.ruicar.afs.cloud.batch.mapper.AfsBatchJobGroupInfoMapper;
import com.ruicar.afs.cloud.batch.service.AfsBatchJobGroupInfoService;
import com.ruicar.afs.cloud.common.core.constant.CommonConstants;
import com.ruicar.afs.cloud.common.core.exception.AfsBaseException;
import com.ruicar.afs.cloud.common.data.datasource.annotation.DS;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class AfsBatchJobGroupInfoServiceImpl extends ServiceImpl<AfsBatchJobGroupInfoMapper, AfsBatchJobGroupInfo> implements AfsBatchJobGroupInfoService {

    @Override
    @DS(CommonConstants._BASE_DS_NAME)
    public boolean checkHasDepends(String systemName,String batchNo) {
        AfsBatchJobGroupInfo afsBatchJobGroupInfo =this.getOne(Wrappers.<AfsBatchJobGroupInfo>lambdaQuery().eq(AfsBatchJobGroupInfo::getSystemName,systemName).eq(AfsBatchJobGroupInfo::getBatchNo,batchNo));
        if(afsBatchJobGroupInfo ==null){
            throw new AfsBaseException("批量编号不存在");
        }
        return StringUtils.isNotEmpty(afsBatchJobGroupInfo.getDependBatchNo());
    }
}
